

<!DOCTYPE html>
<html lang="en" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/my_blog/img/favicon.ico">
  <link rel="icon" type="image/png" href="/my_blog/img/favicon.ico">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
    <meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="">
  <meta name="author" content="John Doe">
  <meta name="keywords" content="">
  <title>微信小程序中用户拒绝授权的处理方法 - Defame。</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/my_blog/lib/hint/hint.min.css" />

  
    
    <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/github-gist.min.css" />
  

  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_6peoq002giu.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_pjno9b9zyxs.css">


<link  rel="stylesheet" href="/my_blog/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/my_blog/js/utils.js" ></script>
  <script  src="/my_blog/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 4.2.1"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/my_blog/">&nbsp;<strong>Defame。</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my_blog/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my_blog/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my_blog/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my_blog/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/my_blog/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" href="javascript:">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner intro-2" id="background" parallax=true
         style="background: url('/my_blog/img/jq.jpg') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container page-header text-center fade-in-up">
            <span class="h2" id="subtitle">
              
            </span>

            
              
  <div class="mt-3 post-meta">
    <i class="iconfont icon-date-fill" aria-hidden="true"></i>
    <time datetime="2020-08-03 15:03" pubdate>
      August 3, 2020 pm
    </time>
  </div>


<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      1.9k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      22
       分钟
    </span>
  

  
  
</div>

            
          </div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto" id="post">
            <!-- SEO header -->
            <h1 style="display: none">微信小程序中用户拒绝授权的处理方法</h1>
            
            <div class="markdown-body" id="post-body">
              <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><h4 id="最近一段时间都在研究微信小程序的开发，相对于app的开发确实上手会容易很多，但是也会存在一些问题。因此，我想记录一下自己在微信小程序开发中遇到的问题，方便日后查阅。"><a href="#最近一段时间都在研究微信小程序的开发，相对于app的开发确实上手会容易很多，但是也会存在一些问题。因此，我想记录一下自己在微信小程序开发中遇到的问题，方便日后查阅。" class="headerlink" title="最近一段时间都在研究微信小程序的开发，相对于app的开发确实上手会容易很多，但是也会存在一些问题。因此，我想记录一下自己在微信小程序开发中遇到的问题，方便日后查阅。"></a>最近一段时间都在研究微信小程序的开发，相对于app的开发确实上手会容易很多，但是也会存在一些问题。因此，我想记录一下自己在微信小程序开发中遇到的问题，方便日后查阅。</h4><h3 id="1、微信小程序当中的权限介绍"><a href="#1、微信小程序当中的权限介绍" class="headerlink" title="1、微信小程序当中的权限介绍"></a>1、微信小程序当中的权限介绍</h3><p>我们平时使用小程序时可能会遇到过进行某个操作之前弹出授权框的场景，需要用户手动授权后才能进行下一步的操作。接下来简单的介绍一下微信小程序的授权制，基本上都是参考自<a href="https://developers.weixin.qq.com/miniprogram/dev/framework/" target="_blank" rel="noopener"><font color="#0681d0" size="3">官方文档</font></a>，大家可以直接阅读官方文档，了解更详细的介绍。<br>微信小程序中所有需要授权的操作和对应的权限关系图:</p>
<img src="/my_blog/2020/08/03/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F%E4%B8%AD%E7%94%A8%E6%88%B7%E6%8B%92%E7%BB%9D%E6%8E%88%E6%9D%83%E7%9A%84%E5%A4%84%E7%90%86%E6%96%B9%E6%B3%95/01.png" srcset="/my_blog/img/loading.gif" class title="This is an example image">
<p>和Android开发不同的是，微信小程序不需要通过代码来申请权限，在调用上述接口时会自动弹出授权框让用户进行授权。但是应该注意的是，<b>一旦用户选择了拒绝或者允许该权限，那么授权关系就会被记录在后台，直到用户主动删除小程序，之后再次调用该API时都不会再弹出权限申请框。</b>如果用户拒绝了授权，之后调用该API都会失败(执行对应的fail回调)，因此我们要根据实际的开发场景处理好用户拒绝授权的情况，如果API的返回值是必需的，那么我们就要在用户拒绝授权后引导用户手动开启该权限从而保证API的成功调用。以下就用获取位置信息API(wx.getLocation)为例，介绍一下如何处理用户拒绝授权的情况。</p>
<h3 id="2、如何处理用户拒绝授权的情况"><a href="#2、如何处理用户拒绝授权的情况" class="headerlink" title="2、如何处理用户拒绝授权的情况"></a>2、如何处理用户拒绝授权的情况</h3><p>下面就以调用<font color="#c7254e" size="3">wx.getLocation()</font>获取用户位置信息为例介绍一下用户拒绝授权的处理方式。<br><b>scope.userLocation</b>和<b>scope.userLocationBackground</b>权限比较特殊，需要在小程序的根目录下的app.json文件中配置位置信息的用途说明,如下所示:</p>
<pre><code class="hljs 1c"><span class="hljs-string">"permission"</span>: &#123;
  <span class="hljs-string">"scope.userLocation"</span>: &#123;
    <span class="hljs-string">"desc"</span>: <span class="hljs-string">"您的位置信息将用于定位"</span>
  &#125;
&#125;</code></pre>
<p>其中的”desc”就是展示给用户的位置信息用途说明，之后在调用<font color="#c7254e" size="3">wx.getLocation()</font>时就会弹出如下授权提示框:</p>
<img src="/my_blog/2020/08/03/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F%E4%B8%AD%E7%94%A8%E6%88%B7%E6%8B%92%E7%BB%9D%E6%8E%88%E6%9D%83%E7%9A%84%E5%A4%84%E7%90%86%E6%96%B9%E6%B3%95/02.png" srcset="/my_blog/img/loading.gif" class title="This is an example image">
<p>根据此前的介绍，当用户点击了”拒绝”后，此后调用<font color="#c7254e" size="3">wx.getLocation()</font>时都会执行fail失败调用，无法获取用户位置信息，因此我们可以在fail回调中判断用户是否拒绝了授权，对于用户拒绝授权的情况调用<font color="#0681d0" size="3">wx.openSetting</font>跳转到小程序设置页面，引导用户手动开始权限。判断用户是否拒绝授权的方式有以下两种:</p>
<h4 id="·-通过wx-getSetting-获取用户当前的授权状态来判断"><a href="#·-通过wx-getSetting-获取用户当前的授权状态来判断" class="headerlink" title="· 通过wx.getSetting()获取用户当前的授权状态来判断"></a>· 通过<font color="#c7254e" size="3">wx.getSetting()</font>获取用户当前的授权状态来判断</h4><p>我们可以在<font color="#c7254e" size="3">wx.getLocation()</font>的fail回调中调用<font color="#c7254e" size="3">wx.getSetting()</font>来获取用户当前授权状态，从而判断用户是否拒绝了定位权限，示例代码如下：</p>
<pre><code class="hljs javascript">wx.getLocation(&#123;
  success: <span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> &#123;
    <span class="hljs-built_in">console</span>.log(res);
  &#125;,
  fail: <span class="hljs-function"><span class="hljs-params">e</span> =&gt;</span> &#123;
    <span class="hljs-built_in">console</span>.log(e);
    <span class="hljs-comment">// 判断用户是否拒绝了授权</span>
    wx.getSetting(&#123;
      success: <span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> &#123;
        <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span>(res.authSetting[<span class="hljs-string">'scope.userLocation'</span>]) != <span class="hljs-string">'undefined'</span> &amp;&amp; !res.authSetting[<span class="hljs-string">'scope.userLocation'</span>]) &#123;
          <span class="hljs-comment">// 用户拒绝了授权，跳转设置页面</span>
          
        &#125;
      &#125;
    &#125;);
  &#125;
&#125;);</code></pre>
<p>大家可能会问，为什么不能直接根据<font color="#c7254e" size="3">!res.authSetting[‘scope.userLocation’]</font>来判断呢?这是因为<font color="#c7254e" size="3">wx.getSetting</font><b>的返回值中只会出现小程序已经向用户申请过的权限</b>，也就是说，只有此前弹出过权限申请框，并且用户点击了”拒绝”或者”允许”，之后在<font color="#c7254e" size="3">wx.getSetting</font>的success回调中才能获取到<font color="#c7254e" size="3">res.authSetting[‘scope.userLocation’]</font>的值。当调用<font color="#c7254e" size="3">wx.getLocation</font>弹出权限申请框后，用户没有点击”拒绝”或”允许”按钮，而是通过系统返回键关闭了权限申请框，之后也会执行fail回调。<br>但是此时<font color="#c7254e" size="3">res.authSetting</font>中是没有<font color="#c7254e" size="3">scope.userLocation</font>属性的，同样满足<font color="#c7254e" size="3">!res.authSetting[‘scope.userLocation’]</font>条件，这种情况跳转设置页面是不太符合逻辑的。还有一个原因，<font color="#c7254e" size="3">wx.openSetting</font><b>同样只会显示小程序已经向用户申请过的权限</b>，因此这种情况即使跳转了设置页面，页面中也不会显示出该权限，当然也无法引导用户手动开启了。</p>
<p>对于用户拒绝定位权限的情况，我们需要同时考虑这三种错误信息，示例代码如下：</p>
<pre><code class="hljs javascript">wx.getLocation(&#123;
  success: <span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> &#123;
    <span class="hljs-built_in">console</span>.log(res);
  &#125;,
  fail: <span class="hljs-function"><span class="hljs-params">e</span> =&gt;</span> &#123;
    <span class="hljs-built_in">console</span>.log(e);
    <span class="hljs-comment">// 判断用户是否拒绝了授权</span>
    <span class="hljs-keyword">if</span> (e.errMsg == <span class="hljs-string">'getLocation:fail:auth denied'</span> || e.errMsg == <span class="hljs-string">'getLocation:fail auth deny'</span> || e.errMsg == <span class="hljs-string">'getLocation:fail authorize no response'</span>) &#123;
      <span class="hljs-comment">// 用户拒绝了授权，跳转设置页面</span>
    &#125;
  &#125;
&#125;);</code></pre>
<p>由于授权失败对应的错误信息是不唯一的,因此我不是很推荐使用这种方式来判断。<br>之后对于用户拒绝授权的情况就可以调用<font color="#c7254e" size="3">wx.openSetting</font>打开设置页面，引导用户手动开启权限了。</p>
<pre><code class="hljs arcade"><span class="hljs-comment">// 用户拒绝了授权，跳转设置页面</span>
wx.openSetting(&#123;
  success: <span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> &#123;
    <span class="hljs-keyword">if</span> (res.authSetting[<span class="hljs-string">'scope.userLocation'</span>]) &#123;
      <span class="hljs-comment">// 授权成功，重新定位</span>
      wx.getLocation(&#123;
        success: <span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> &#123;&#125;
      &#125;);
    &#125; <span class="hljs-keyword">else</span> &#123;
      <span class="hljs-comment">// 没有允许定位权限</span>
      wx.showToast(&#123;
        title: <span class="hljs-string">'您拒绝了定位权限，将无法使用XX功能'</span>,
        icon: <span class="hljs-string">'none'</span>
      &#125;);
    &#125;
  &#125;
&#125;);</code></pre>
<p>在<font color="#c7254e" size="3">wx.openSetting</font>的success回调中可以判断用户是否已授权，并根据实际开发场景执行相关逻辑，这里为了简单演示，对于用户已授权的情况重新调用wx.getLocation进行定位；对于用户依然没有授权的情况，弹出一个Toast提示。</p>
<p>需要注意，官方文档中明确指出从2.3.0版本开始，当用户发生点击行为后才可以跳转打开设置页，不允许在用户无任何操作的情况下进行跳转，对于该限制，我们可以使用弹出一个模态框，当用户点击确定按钮时再跳转设置页面。最后附上定位的完整代码如下：</p>
<pre><code class="hljs javascript">wx.getLocation(&#123;
  success: <span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> &#123;
    <span class="hljs-built_in">console</span>.log(res);
  &#125;,
  fail: <span class="hljs-function"><span class="hljs-params">e</span> =&gt;</span> &#123;
    <span class="hljs-built_in">console</span>.log(e);
    <span class="hljs-comment">// 判断用户是否拒绝了授权</span>
    wx.getSetting(&#123;
      success: <span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> &#123;
        <span class="hljs-keyword">if</span> (<span class="hljs-keyword">typeof</span>(res.authSetting[<span class="hljs-string">'scope.userLocation'</span>]) != <span class="hljs-string">'undefined'</span> &amp;&amp; !res.authSetting[<span class="hljs-string">'scope.userLocation'</span>]) &#123;
          <span class="hljs-comment">// 用户拒绝了授权</span>
          wx.showModal(&#123;
            title: <span class="hljs-string">'提示'</span>,
            content: <span class="hljs-string">'您拒绝了定位权限，将无法使用XX功能'</span>,
            success: <span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> &#123;
              <span class="hljs-keyword">if</span> (res.confirm) &#123;
                <span class="hljs-comment">// 跳转设置页面</span>
                wx.openSetting(&#123;
                  success: <span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> &#123;
                    <span class="hljs-keyword">if</span> (res.authSetting[<span class="hljs-string">'scope.userLocation'</span>]) &#123;
                      <span class="hljs-comment">// 授权成功，重新定位</span>
                      wx.getLocation(&#123;
                        success: <span class="hljs-function"><span class="hljs-params">res</span> =&gt;</span> &#123;&#125;
                      &#125;);
                    &#125; <span class="hljs-keyword">else</span> &#123;
                      <span class="hljs-comment">// 没有允许定位权限</span>
                      wx.showToast(&#123;
                        title: <span class="hljs-string">'您拒绝了定位权限，将无法使用XX功能'</span>,
                        icon: <span class="hljs-string">'none'</span>
                      &#125;);
                    &#125;
                  &#125;
                &#125;);
              &#125;
            &#125;
          &#125;);
        &#125;
      &#125;
    &#125;);
&#125;);</code></pre>
<p>最后展示一下运行效果：</p>
<img src="/my_blog/2020/08/03/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F%E4%B8%AD%E7%94%A8%E6%88%B7%E6%8B%92%E7%BB%9D%E6%8E%88%E6%9D%83%E7%9A%84%E5%A4%84%E7%90%86%E6%96%B9%E6%B3%95/03.gif" srcset="/my_blog/img/loading.gif" class title="This is an example image">

<h3 id="总结"><a href="#总结" class="headerlink" title="总结:"></a>总结:</h3><p>由于微信小程序只会向用户申请一次授权，之后的授权记录会一直保留，并且用户拒绝授权会导致相关API调用失败，因此我们需要考虑用户拒绝授权的情况。本文以获取位置信息的API为例，介绍了微信小程序中如何处理这种情况，对于其他权限来说逻辑也是类似的，主要包括两个步骤：<br>1.判断用户是否拒绝了授权。<br>2.对于用户拒绝授权的情况，跳转小程序设置页面引导用户手动授权。</p>
<h3 id="参考文章"><a href="#参考文章" class="headerlink" title="参考文章"></a>参考文章</h3><p><a href="https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/authorize.html" target="_blank" rel="noopener"><font color="#0681d0" size="3">微信小程序官方文档——授权</font></a><br>声明：图片和内容来自网络，我只是知识的搬运工，侵删<br>转载自：<a href="https://www.jianshu.com/p/80e33d16182f" target="_blank" rel="noopener">https://www.jianshu.com/p/80e33d16182f</a></p>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/my_blog/categories/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F/">微信小程序</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/my_blog/tags/%E5%BE%AE%E4%BF%A1%E5%B0%8F%E7%A8%8B%E5%BA%8F/">微信小程序</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" target="_blank" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！</p>
              
              
                <div class="post-prevnext row">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/my_blog/2020/08/17/Vue%E7%9F%A5%E8%AF%86%E7%82%B9%E6%95%B4%E7%90%86/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">Vue知识点整理</span>
                        <span class="visible-mobile">Previous</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/my_blog/2020/07/29/%E9%97%AD%E5%8C%85%E7%9A%84%E8%AF%A6%E8%A7%A3/">
                        <span class="hidden-mobile">闭包的详解</span>
                        <span class="visible-mobile">Next</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
              <!-- Comments -->
              <article class="comments" id="comments">
                
                
  <div class="disqus" style="width:100%">
    <div id="disqus_thread"></div>
    <script type="text/javascript">
      function loadDisqus() {
        var disqus_config = function () {
          this.page.url = 'https://defame.gitee.io/my_blog/2020/08/03/微信小程序中用户拒绝授权的处理方法/';
          this.page.identifier = '/2020/08/03/微信小程序中用户拒绝授权的处理方法/';
        };
        (function () {
          var d = document,
            s = d.createElement('script');
          s.src = '//' + '' + '.disqus.com/embed.js';
          s.setAttribute('data-timestamp', new Date());
          (d.head || d.body).appendChild(s);
        })();
      }
      waitElementVisible('disqus_thread', loadDisqus);
    </script>
    <noscript>Please enable JavaScript to view the
      <a href="https://disqus.com/?ref_noscript" target="_blank" rel="nofollow noopener noopener">comments powered by Disqus.</a>
    </noscript>
  </div>


              </article>
            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;TOC</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">Search</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">keyword</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  

  <footer class="mt-5">
  <div class="text-center py-3">
    <div>
      <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a>
      <i class="iconfont icon-love"></i>
      <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener">
        <span>Fluid</span></a>
    </div>
    
  <div class="statistics">
    
    

    
      
        <!-- 不蒜子统计PV -->
        <span id="busuanzi_container_site_pv" style="display: none">
            总访问量 
            <span id="busuanzi_value_site_pv"></span>
             次
          </span>
      
      
        <!-- 不蒜子统计UV -->
        <span id="busuanzi_container_site_uv" style="display: none">
            总访客数 
            <span id="busuanzi_value_site_uv"></span>
             人
          </span>
      
    
  </div>


    
  <!-- 备案信息 -->
  <div class="beian">
    <a href="http://beian.miit.gov.cn/" target="_blank"
       rel="nofollow noopener">京ICP证123456号</a>
    
      <a
        href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=12345678"
        rel="nofollow noopener"
        class="beian-police"
        target="_blank"
      >
        <span class="beian-police-sep">&nbsp;|&nbsp;</span>
        
          <img src="/my_blog/img/police_beian.png" srcset="/my_blog/img/loading.gif" alt="police-icon" />
        
        <span>京公网安备12345678号</span>
      </a>
     
  </div>


    
  </div>
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/my_blog/js/debouncer.js" ></script>
<script  src="/my_blog/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/my_blog/js/lazyload.js" ></script>
  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/my_blog/js/clipboard-use.js" ></script>



  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: '#post-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 0,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    var typed = new Typed('#subtitle', {
      strings: [
        '  ',
        "微信小程序中用户拒绝授权的处理方法&nbsp;",
      ],
      cursorChar: "_",
      typeSpeed: 70,
      loop: false,
    });
    typed.stop();
    $(document).ready(function () {
      $(".typed-cursor").addClass("h2");
      typed.start();
    });
  </script>



  <script  src="https://cdn.staticfile.org/anchor-js/4.2.2/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script  src="/my_blog/js/local-search.js" ></script>
  <script>
    var path = "/my_blog/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>







  
  
    <script>
      !function (e, t, a) {
        function r() {
          for (var e = 0; e < s.length; e++) s[e].alpha <= 0 ? (t.body.removeChild(s[e].el), s.splice(e, 1)) : (s[e].y--, s[e].scale += .004, s[e].alpha -= .013, s[e].el.style.cssText = "left:" + s[e].x + "px;top:" + s[e].y + "px;opacity:" + s[e].alpha + ";transform:scale(" + s[e].scale + "," + s[e].scale + ") rotate(45deg);background:" + s[e].color + ";z-index:99999");
          requestAnimationFrame(r)
        }

        function n() {
          var t = "function" == typeof e.onclick && e.onclick;
          e.onclick = function (e) {
            t && t(), o(e)
          }
        }

        function o(e) {
          var a = t.createElement("div");
          a.className = "heart", s.push({
            el: a,
            x: e.clientX - 5,
            y: e.clientY - 5,
            scale: 1,
            alpha: 1,
            color: c()
          }), t.body.appendChild(a)
        }

        function i(e) {
          var a = t.createElement("style");
          a.type = "text/css";
          try {
            a.appendChild(t.createTextNode(e))
          } catch (t) {
            a.styleSheet.cssText = e
          }
          t.getElementsByTagName("head")[0].appendChild(a)
        }

        function c() {
          return "rgb(" + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + "," + ~~(255 * Math.random()) + ")"
        }

        var s = [];
        e.requestAnimationFrame = e.requestAnimationFrame || e.webkitRequestAnimationFrame || e.mozRequestAnimationFrame || e.oRequestAnimationFrame || e.msRequestAnimationFrame || function (e) {
          setTimeout(e, 1e3 / 60)
        }, i(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: fixed;}.heart:after{top: -5px;}.heart:before{left: -5px;}"), n(), r()
      }(window, document);
    </script>
  














<script src="/my_blog/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body>
</html>
